package com.yunji.base.provide;

import com.yunji.base.domain.BelongDO;
import com.yunji.base.service.BelongService;
import com.yunji.common.utils.ConvertDataUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author : peter-zhu
 * @date : 2024/12/12 15:33
 * @description : TODO
 **/
@Component
public class BaseDataBelongProvide {
    @Resource
    BelongService belongService;

    public Map<Long, BelongDO> getBelongMap(List<Long> belongIds) {
        return ConvertDataUtil.getDataMap(() -> getBelongList(belongIds), BelongDO::getBelongId);
    }

    public List<BelongDO> getBelongList(List<Long> belongIds) {
        return belongService.listByIds(belongIds);
    }

    public void updateBelong(BelongDO update) {
        Assert.isTrue(belongService.update(update), "修改失败");
    }

    public Integer selectStockStatus(Long belongId) {
        return belongService.selectStockStatus(belongId);
    }

}
